<?php

require_once './include/common.inc.php';
checkLogin();
$page_title = 'jans2en furniture - Products - Clearance Sale';
$menu_id = 5;
$noproductNote='No product in this category.';


$sqlWhere = ''; //
$sqlOrderBy = '';//
$sql = '';
$listPage = 'product_photo_list.php';
if ($jansen_type > 0 && $jansen_uid > 0) 
{	
	$listPage = 'clearance.php';
}

$vNull = null;
$urlParam = '';

$postiondiv='';
$baner_img='';
$positionName = '';
$parViewAll = '';
if($fid > 0) $parViewAll = '&viewall=1';
else $parViewAll = '&viewall=1';
$ViewAllUrl = '';

$page_url = $listPage.'?';
$ViewAllUrl = $listPage.'?'.$parViewAll;
$sqlWhere = " WHERE c.publish=1 AND c.`id`=pc.`category_id`  AND pc.`product_id`=p.`id`  AND p.`hidden_flag`=0  AND p.auction = 1  AND p.time_start < ".time()." AND p.time_end > ".(time()-86400)."  GROUP BY p.`id`";
$sqlOrderBy = " ORDER BY p.`time_start`";

$category_list = GetCategoryTable($_categories,$listPage."?categoryid=%d",0,'clearance',0,&$vNull);

$postiondiv .='<div class="position" id="position"><a href="index.php">Home</a>&gt; <a href="'.$listPage.'">Clearance Sale</a></div>';

$baner_img = GetBannerImg($positionName);

// *** page code start ***
$sql = "SELECT p.`id` FROM `product` p, `product_category` pc, `category` c".$sqlWhere;
$query = $db->query($sql);
$sql_all_num = $db->num_rows($query);

$ppp = 12;
getMyParam('page');
$page = empty($page) || !ispage($page) ? 1 : $page;
$start_limit = ($page - 1) * $ppp;
if($start_limit > $sql_all_num) {
	$start_limit = 0;
	$page = 1;
}
$page_show = getPhotoPageStr($sql_all_num, $page, $ppp, $page_url);
// *** page code end ***

$sql_limit = 'LIMIT '.$start_limit.', '.$ppp;
if($viewall!='')
	$sql_limit = '';

$sql = "SELECT p.`id`, p.`code`, p.`name`, p.`price_1`, p.`price_2`, p.`price_3`, p.`small_pic`, p.`pic`, p.`new_flag` , p.`comment`, p.`finish_id`,
p.`discount`,p.`interval`,p.`time_start`,p.`time_end`,p.`is_soldout`,c.seq  FROM `product` p, `product_category` pc, `category` c".$sqlWhere.$sqlOrderBy.$sql_limit;
$photo_ary = array();
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
	$rs['code'] = strtoupper($rs['code']);
	$photo_ary[] = $rs;
}

$PagerString = '&nbsp;&nbsp;&nbsp;&nbsp;<a target="_self" href="'.$ViewAllUrl.'">View all</a>';
if($sql_all_num > 0)
	$PagerString = '	Page &nbsp; &nbsp;   '.$page_show['pagelink'].$PagerString;
		
if($viewall !='') 
{
	$PagerString = 'Viewing all '.$sql_all_num.' Records.';
	$page_show['str'] = 'You are now viewing all of the products';
	if($positionName != '')
		$page_show['str'] .= ' in "'.$positionName.'".';
}

require_once PrintEot('header3');
require_once PrintEot('clearance');
require_once PrintEot('footer');

?>